package com.ty.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ty.common.annotation.Log;
import com.ty.common.core.controller.BaseController;
import com.ty.common.core.domain.AjaxResult;
import com.ty.common.enums.BusinessType;
import com.ty.system.domain.MedicalReport;
import com.ty.system.service.IMedicalReportService;
import com.ty.common.utils.poi.ExcelUtil;
import com.ty.common.core.page.TableDataInfo;

/**
 * 体检报告Controller
 *
 * @author
 * @date 2024-05-26
 */
@RestController
@RequestMapping("/system/report")
public class MedicalReportController extends BaseController
{
    @Autowired
    private IMedicalReportService medicalReportService;

    /**
     * 查询体检报告列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MedicalReport medicalReport)
    {
        startPage();
        List<MedicalReport> list = medicalReportService.selectMedicalReportList(medicalReport);
        return getDataTable(list);
    }

    /**
     * 获取体检报告详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(medicalReportService.selectMedicalReportById(id));
    }

    /**
     * 新增体检报告
     */
    @Log(title = "体检报告", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MedicalReport medicalReport)
    {
        return toAjax(medicalReportService.insertMedicalReport(medicalReport));
    }

    /**
     * 修改体检报告
     */
    @Log(title = "体检报告", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MedicalReport medicalReport)
    {
        return toAjax(medicalReportService.updateMedicalReport(medicalReport));
    }

    /**
     * 删除体检报告
     */
    @Log(title = "体检报告", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(medicalReportService.deleteMedicalReportByIds(ids));
    }
}
